package com.shjn.squirrel.fragment;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;

import com.google.gson.Gson;
import com.shjn.squirrel.R;
import com.shjn.squirrel.application.MyApplication;
import com.shjn.squirrel.bean.httpBean.DeviceIdReq;
import com.shjn.squirrel.bean.httpBean.RespCommonResult;
import com.shjn.squirrel.customView.BackAndTimerView;
import com.shjn.squirrel.model.Constant;
import com.shjn.squirrel.model.LocalStorage;
import com.shjn.squirrel.model.UserInfoCache;
import com.shjn.squirrel.utils.Base64Utils;
import com.shjn.squirrel.utils.OkhttpHelper;
import com.shjn.squirrel.utils.SoundPlayUtils;

import java.io.IOException;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;

/**
 * 用户扫码登录
 */
public class UserScanFragment extends BaseFragment implements View.OnClickListener {

    private static UserScanFragment instance;
    private Button mSwitchTelLogin;
    private ImageView userQRcode;

    public UserScanFragment() {
    }

    public synchronized static UserScanFragment getInstance() {
        if (instance == null) {
            instance = new UserScanFragment();
        }
        return instance;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return createView(inflater, R.layout.user_scan_login, container);
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initTimer();
        initView();
    }

    /**
     * 初始化倒计时器
     */
    private void initTimer() {
        //加载定时器面板，设置定时时间
        mActivity.mBackAndTimer.setOnBackListener(new BackAndTimerView.OnBackListener() {
            @Override
            public void onBack() {
                //返回首页
                if (!UserSelectFragment.getInstance().isAdded()) {
                    mActivity.mBackAndTimer.setVisibleState(false);
                    mActivity.getFragmentManager().beginTransaction()
                            .replace(R.id.mid, UserSelectFragment.getInstance())
                            .commit();
                    TopFragment.getInstance().mBtnMyRecycler.setVisibility(View.VISIBLE);
                }
            }
        }).setBackVisibleState(true).setOnTimerFinishListener(new BackAndTimerView.OnTimerFinishListener() {
            @Override
            public void onTimerFinish() {
                //返回首页
                if (!UserSelectFragment.getInstance().isAdded()) {
                    mActivity.mBackAndTimer.setVisibleState(false);
                    mActivity.getFragmentManager().beginTransaction()
                            .replace(R.id.mid, UserSelectFragment.getInstance())
                            .commit();
                    TopFragment.getInstance().mBtnMyRecycler.setVisibility(View.VISIBLE);
                }
            }
        }).setTime(60).setVisibleState(true).start();
    }

    /**
     * 初始化相关控件
     */
    private void initView() {
        //切换至手机号登录按钮,绑定点击事件
        mSwitchTelLogin = (Button) mView.findViewById(R.id.btn_switch_tel);
        mSwitchTelLogin.setOnClickListener(this);
        //获取二维码
        userQRcode = (ImageView) mView.findViewById(R.id.img_user_qrcode);

        //------测试使用-----//
        String base64Imag = "iVBORw0KGgoAAAANSUhEUgAAAQQAAAEECAYAAADOCEoKAAAa1UlEQVR4Xu2d7XqbRw5Dm/u/6O6jtF1/xPY5rwlRowT7dzggCJLQyPamP/7++++//+r/qkAVqAJ//fXXjxpC56AKVIH/FKghdBaqQBX4vwI1hA5DFagCNYTOQBWoAr8q0BdCp6IKVIG+EDoDVaAK9IXQGagCVeALBfArw48fP/4YATf+JIP0NBymGHT/1nDDYzoYxMNwmGLQ/WmNJ91XetLfIVSwbEtJT9U0MGnCIA41hGzPT0Gjubjx7AvhVbeMYNPm0jIaDlMMul9DmHb5zPtqtvpCeGmeEWzaalpGw2GKQfdrCNMun3lfzVYNoYbw0fia4ZmOPRmT4TDFoPvTGk+6r/SsIdQQaggnre39uNQQLmprBLsI+Us4fSIZDlMMut+vDNMun3lfzVZfCH0h9IVw5gKnWa0YgkmSLuw7eIlPRcIwWiQwqP5EjikG3aca7CuF8lBP6L7lYeq5dwzVQlrc+I1/7WiS3FsIg09imcYThtEigUH1JnJMMeg+1WD68XOAf5O/yTB6UMxUixrCO4VpoSOCDweYhiKxJAkM0srUQf3Y4ml4mHruHUOamzr6QnjVJRIsIngNQe8F9aOG8FbKyHxOf6homqYn4I6BJJZ5ohK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AAASUVORK5CYII=";
        Bitmap bitmap = Base64Utils.base64ToBitmap(base64Imag);
        //设置二维码
        userQRcode.setImageBitmap(bitmap);
//        OkhttpHelper.postRequest(Constant.baseUrl + "machine/QRCode/user",
//                new Gson().toJson(new DeviceIdReq(LocalStorage.getDeviceID(MyApplication.getInstance()))),
//                new Callback() {
//                    @Override
//                    public void onFailure(Call call, IOException e) {
//                        Log.i("info", "userQRcode_onFailure: " + e.getMessage());
//                    }
//
//                    @Override
//                    public void onResponse(Call call, Response response) throws IOException {
//                        RespCommonResult result = new Gson().fromJson(response.body().string(), RespCommonResult.class);
//                        if (result.getStateCode() == 1) {
//                            String base64Imag = (String) result.getResult().get("base64Img");
//                            final Bitmap bitmap = Base64Utils.base64ToBitmap(base64Imag);
//                            mActivity.runOnUiThread(new Runnable() {
//                                @Override
//                                public void run() {
//                                    if (UserScanFragment.getInstance().isAdded()) {
//                                        //设置二维码
//                                        userQRcode.setImageBitmap(bitmap);
//                                        //轮询服务器是否有用户扫描了二维码
//                                        OkhttpHelper.postRequest(Constant.baseUrl + "machine/verification/getScanUser",
//                                                new Gson().toJson(new DeviceIdReq(LocalStorage.getDeviceID(MyApplication.getInstance()))),
//                                                new Callback() {
//                                                    @Override
//                                                    public void onFailure(Call call, IOException e) {
//                                                        Log.i("info", "getScanUser_onFailure: " + e.getMessage());
//                                                    }
//
//                                                    @Override
//                                                    public void onResponse(Call call, Response response) throws IOException {
//                                                        final RespCommonResult result = new Gson().fromJson(response.body().string(), RespCommonResult.class);
//                                                        if (result.getStateCode() == 1) {
////                                                            mActivity.runOnUiThread(new Runnable() {
////                                                                @Override
////                                                                public void run() {
////                                                                    if (UserScanFragment.getInstance().isAdded()) {
////                                                                        mActivity.mBackAndTimer.stop();
////                                                                        UserInfoCache.loginState = true;
////                                                                        UserInfoCache.telNum = (String) result.getResult().get("teleNum");
////                                                                        if (UserInfoCache.category.equals(Constant.bottle)) {
////                                                                            SoundPlayUtils.play(17);//饮料瓶投递语音提示
////                                                                        } else {
////                                                                            SoundPlayUtils.play(13);//其它种类垃圾开箱语音投递
////                                                                        }
////                                                                        //打开投口
//////                                                                        mActivity.serialPortUtils.sendSerialPort("androidC51:" + Constant.numberMap.get(Constant.categoryMap.get(UserInfoCache.category)[3]) + ";");
////                                                                        //跳转到开箱投递页面
////                                                                        getActivity().getFragmentManager().beginTransaction()
////                                                                                .replace(R.id.mid, UserOpenDeliverFragment.getInstance())
////                                                                                .commit();
////
////                                                                    }
////                                                                }
////                                                            });
//                                                        } else {
//                                                            if (UserScanFragment.getInstance().isAdded()) {
//                                                                //轮询
//                                                                OkhttpHelper.requestAgain(call, this);
//                                                                Log.i("info", "userScanCheck again!");
//                                                            }
//                                                        }
//                                                    }
//                                                });
//                                    }
//                                }
//                            });
//                        }
//                    }
//                });

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            //跳转到用户手机号登录页面
            case R.id.btn_switch_tel:
                if (!UserTeleFragment.getInstance().isAdded()) {
                    mActivity.mBackAndTimer.stop();
                    mActivity.getFragmentManager().beginTransaction()
                            .replace(R.id.mid, UserTeleFragment.getInstance())
                            .commit();
                }
                break;
            default:
                break;
        }
    }
}
